﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace Pakxel.Framework
{
    class SqlQuerys
    {
        XElement root;
        
        public SqlQuerys(XElement root)
        {
            this.root = root;
        }

        public SqlQuery getSqlQuery(string Id)
        {
            SqlQuery iSqlQuery=null;
            var XmlConnectionString = from Connections in root.Descendants("SqlQuerys").Descendants("SqlQuery")
                                      let B = ((string)Connections.Element("Id"))
                                      where B.Equals(Id)
                                      select Connections;
            if (XmlConnectionString != null)
            {
                foreach (XElement e in XmlConnectionString)
                {
                    iSqlQuery= new SqlQuery((string)e.Element("Id"), (string)e.Element("Description"), (string)e.Element("Query"));
                }
            }
            return iSqlQuery;
        }

    }
}
